import json

def build_expression_tree(postfix_expression):
    # 初始化一个空的树
    stack = []

    for token in postfix_expression.split():
        if token.isalpha() or token.isdigit():  # 检查是否为操作数
            node = {"data": token, "children": []}
            stack.append(node)
        else:  # 运算符
            right_child = stack.pop()
            left_child = stack.pop()
            node = {"data": token, "children": [left_child, right_child]}
            stack.append(node)
    
    return stack[0]

def tree_to_json(node, indent=None):
    """将树节点转换为 JSON 字符串"""
    return json.dumps(node, indent=indent)

# 后缀表达式
postfix_expression = "a b + c *"

# 构建表达式树
expression_tree = build_expression_tree(postfix_expression)

# 将树转换为 JSON 字符串
json_tree = tree_to_json(expression_tree, indent=4)

print(json_tree)